<?php
/**
 * Created by JetBrains PhpStorm.
 * User: CAIXUDONG
 * Date: 11-6-20
 * Time: 下午4:17
 */
 
class BaoBeiAlbumController extends Controller{

    public function index(){

        $curr_page = (int)$this->input()->post('pageNum',1);
        $per_page  = (int)$this->input()->post('numPerPage',30);
        $album_name = $this->input()->post('album_name');
        $album_status = $this->input()->post('album_status');
        $filter = array();

        if($album_name){
            $filter['album_name'] = $album_name;
        }

        if($album_status || $album_status !=null){
            $filter['album_status'] = $album_status;
        }

        $list = Model::getInstance('baobeialbum')->getBaoBeiAlbumList($curr_page,$per_page,$filter);
        $data = array(
            'list'=>$list,
        );
        Template::show('baobei/baobeialbum.php',$data);

    }

    public function add(){

        Template::show('baobei/add_baobeialbum.php');
    }

    public function delAlbum(){

        $album_id = $this->input()->get('album_id');
        $ret = Model::getInstance('baobeialbum')->delAlbum($album_id);

        if($ret){
            $data = array(
                "statusCode"=>"200",
                "navTabId"=>"baobeialbum",
            );
            echo Response::JSON($data);
        }else{

            $data = array(
                "statusCode"=>"300",
                "message"=>"删除失败",
            );
            echo Response::JSON($data);
        }
    }

    public function edit(){

        $id = (int)$this->input()->get('id');

        $album_info = Model::getInstance('baobeialbum')->get($id);

        $data = array(
            'album_info'=>$album_info
        );

        Template::show('baobei/edit_baobeialbum.php',$data);
    }
}